<template>
  <div  class="app-container">
    <div>
      <el-button type="primary" size="small" @click="$refs.createForm.show()"
        >新增</el-button
      >
    </div>
      <br />

    <el-table :data="tableData" border style="width: 100%">
      <el-table-column  type="index" label="序号" width="60"> </el-table-column>
      <el-table-column prop="name" label="名称" width="220"> </el-table-column>
      <el-table-column prop="activeVersion" label="版本" width="60">
      </el-table-column>
       <el-table-column prop="description" label="描述" >
      </el-table-column>
      <el-table-column prop="modifiedTime" label="更新日期" width="350">
      </el-table-column>
      <el-table-column prop="creationTime" label="创建日期" width="350">
      </el-table-column>
      <el-table-column> </el-table-column>
      <el-table-column fixed="right" label="操作" width="200">
        <template slot-scope="scope">
            <el-button @click="$refs.updateVersionForm.show(scope.row)" type="text" size="small"
            >版本切换</el-button
          >
       
           <el-button @click="$router.push({ path: '/workflow/simulation',query:{ id: scope.row.id, versionId: scope.row.activeVersion,name:scope.row.name } })" type="text" size="small"
            >模拟</el-button
          >
          <el-button
            type="text"
            size="small"
            @click="$router.push({ path: '/editworkflow/edit',query:{ id: scope.row.id, versionId: scope.row.activeVersion,name:scope.row.name,des:scope.row.description } })"
            >编辑</el-button
          >
           <el-button
            type="text"
            size="small"
            @click="$router.push({ path: '/editworkflow/detail',query:{ id: scope.row.id, versionId: scope.row.activeVersion,name:scope.row.name } })"
            >查看</el-button
          >
        </template>
      </el-table-column>
    </el-table>


    <createForm
      ref="createForm"
      @ok-click="
        wf =>
          $router.push({
            path: '/editworkflow/edit',
            query: { id: wf.id, versionId: wf.activeVersion,name:wf.name }
          })
      "
    ></createForm>
    <!-- 版本切换  -->
    <updateVersionForm ref="updateVersionForm" @ok-click="loadAllWorkflows()">
    </updateVersionForm>
  </div>
</template>

<script>
import createForm from "./createForm";
import updateVersionForm from "./updateVersionForm";
export default {
  components: { createForm ,updateVersionForm},
  methods: {
    handleClick(row) {
      console.log(row);
    }
  },

  data() {
    return {
      tableData: []
    };
  },
  mounted(){
    this.loadAllWorkflows();
  },
  methods: 
  {
    loadAllWorkflows() {
      this.$store.dispatch("workflow/getAllWorkflows", this.form).then(res => {
        this.tableData = res;
      });
    },
  }
};
</script>

<style></style>
